<template>
  <view id="content">
    <view class="setting" @click="userInfo">
      <view style="font-size: 32rpx;margin-left: 20rpx;">个人资料</view>
      <view style="width: 16rpx;height: 28rpx;margin-left: 520rpx;">
        <image src="../../static/sjiantou.png" style="width: 100%; height: 100%;"></image>
      </view>
    </view>
    <view class="setting" @click="updatePwd">
      <view style="font-size: 32rpx;margin-left: 20rpx;">修改密码</view>
      <view style="width: 16rpx;height: 28rpx;margin-left: 520rpx;">
        <image src="../../static/sjiantou.png" style="width: 100%; height: 100%;"></image>
      </view>
    </view>
    <view class="setting" @click="tsChannel">
      <view style="font-size: 32rpx;margin-left: 20rpx;">反馈建议</view>
      <view style="width: 16rpx;height: 28rpx;margin-left: 520rpx;">
        <image src="../../static/sjiantou.png" style="width: 100%; height: 100%;"></image>
      </view>
    </view>
    <view
        style="width: 100%;height: 92rpx;border-radius: 10rpx;display: flex;justify-content: center;align-items: center;margin-top: 700rpx;">
      <button @click="logOut"
              style="width: 700rpx;height: 92rpx;font-size: 36rpx;color: red;background-color: white;">退出登录
      </button>
    </view>
  </view>
</template>

<script>
import config from '../../utils/config.js'
import request from '../../utils/request.js'
import {
  checkLogin
} from '../../utils/common.js'

export default {
  data() {
    return {
      showOverlay: false, // 控制遮罩层显示的变量,
      curUser: {
        'nickName': '游客'
      },
      proxyShow: true,
      dsType: false,
      cyType: false,
      gfType: false,
      ykType: true,
      userImg: ''
    }
  },
  onShow() {
    var _this = this;
    // 不做强制登录校验
    if (checkLogin()) {
      _this.userImg = uni.getStorageSync('userImg');
      _this.getUserInfo();
    }
  },
  onShareAppMessage(res) {
    let pages = getCurrentPages(); //获取当前页面栈的信息
    let currentPage = pages[pages.length - 1]; //获取到当前页面栈中最后一个页面的索引
      if (res.from === 'button') {// 来自页面内分享按钮
        console.log(res.target)
      }
      return {
        title: '逐金污师丨成人情趣甄选好物',
        path: currentPage.route + `?id=${this.id}&share=${this.share}` //后面是路径上要传递的参数
      }
    },
	onShareTimeline(res) {
	  let pages = getCurrentPages(); //获取当前页面栈的信息
	  let currentPage = pages[pages.length - 1]; //获取到当前页面栈中最后一个页面的索引
	    if (res.from === 'button') {// 来自页面内分享按钮
	      console.log(res.target)
	    }
	    return {
	      title: '逐金污师丨成人情趣甄选好物',
	      path: currentPage.route + `?id=${this.id}&share=${this.share}` //后面是路径上要传递的参数
	    }
	  },
  methods: {
    login() {
      uni.navigateTo({
        url: '/pages/login/login?id=zhangsan'
      });
    },
    userInfo() {
      uni.showToast({
        title: '功能建设中',
        icon: 'error',
        duration: 500
      });
    },
    updatePwd() {
      uni.navigateTo({
        url: '/pages/modifypwd/modifypwd'
      })
    },
    tsChannel() {
      if (checkLogin()) {
        uni.navigateTo({
          url: "/pages/fankui/fankui"
        })
      }
    },
    logOut() {
      uni.clearStorageSync("token")
      uni.clearStorageSync("userImg")
      uni.showToast({
        title: '退出成功',
        icon: 'success',
        duration: 1000
      });
      setTimeout(function () {
        uni.switchTab({
          url: '/pages/main/main'
        })
      }, 2000)
    },
    getUserInfo() {
      var _this = this;
      _this.proxyShow = false;
      request({
        url: '/getInfo',
        method: "GET"
      }).then(res => {
        if (200 == res.code) {
          _this.curUser = res.user;
          request({
            url: '/system/user/myteams',
            method: "GET"
          }).then(res => {
            if (200 == res.code) {
              _this.teams = res.data;
              _this.displayuserDetail();
            } else {
              console.error('登录失败');
            }
          })
        } else {
          console.error('查询用户信息');
        }
      })
    },
    displayuserDetail() {
      var _this = this;
      if (_this.curUser.ctype == '董事') {
        _this.dsType = true;
        _this.gfType = false;
        _this.cyType = false;
        _this.ykType = false;
      } else if (_this.curUser.ctype == '官方') {
        _this.dsType = false;
        _this.gfType = true;
        _this.cyType = false;
        _this.ykType = false;
      } else if (_this.curUser.ctype == '创业') {
        _this.dsType = false;
        _this.gfType = false;
        _this.cyType = true;
        _this.ykType = false;
      } else { // 游客
        _this.dsType = false;
        _this.gfType = false;
        _this.cyType = false;
        _this.ykType = true;
      }
    },
    toggleOverlay() {
      var _this = this;
      const token = uni.getStorageSync('token');
      if (!token) {
        _this.showOverlay = !_this.showOverlay;
        return;
      }
      uni.navigateTo({
        url: '/pages/jinengpx/jinengpx'
      })
    },
    dailiOverlay() {
      uni.navigateTo({
        url: '/pages/dailitx/dailitx'
      })
    },
    closed() {
      this.showOverlay = !this.showOverlay;
    },
    jumpMyteam() {
      const token = uni.getStorageSync('token');
      if (!token) {
        this.proxyShow = true;
        uni.navigateTo({
          url: '/pages/login/login'
        })
        return;
      }
      uni.navigateTo({
        url: "/pages/myteam/myteam"
      })
    }
  }
}
</script>

<style>
#content {
  background-color: #f5f5f5;
  height: 100%;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
}

.title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 122rpx;
  margin-top: 20rpx;
  margin-left: 20rpx;
  margin-right: 20rpx;
  /**border: solid 1rpx red; **/
}

.title_info {
  width: 500rpx;
  height: 140rpx;
  display: flex;
  justify-content: start;
  align-items: center;
  font-size: 34rpx;
}

.title_info_txt {
  margin-left: 30rpx;
  font-size: 32rpx;
}

/**弹性盒子纵向排列**/
.title_daili {
  width: 204rpx;
  height: 81rpx;
  display: flex;
  flex-direction: column;
  justify-content: start;
  /**border: solid 1rpx blue;**/
}

/** 一个div中文本垂直居中的方式：height=line-height */
.title_daili_txt {
  line-height: 50rpx;
  height: 50rpx;
  font-size: 24rpx;
  padding-left: 8rpx;
  color: yellowgreen;
  background-color: black;
  /** border-radius: 10rpx; **/
}

/**收益**/
.shouyi {
  height: 280rpx;
  /** border: solid 1rpx yellow;**/
  background-color: yellow;
  margin-top: 30rpx;
  margin-left: 10rpx;
  margin-right: 10rpx;
  border-radius: 20rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  background-image: url(http://127.0.0.1:8098/libs/shouyi_img.png);
}

/**本月收益**/
.benyue_shouyi {
  /** border: solid 1rpx red; **/
  height: 150rpx;
  padding-left: 20rpx;
  padding-top: 20rpx;
}

/**本月收益描述**/
.benyue_shouyi_desc {
  font-size: 30rpx;
}

/**本月收益文本**/
.benyue_shouyi_txt {
  font-size: 48rpx;
  font-weight: 600;
}

/**累计收入**/
.zong_shouyi {
  /** border: solid 1rpx black; **/
  display: flex;
  justify-content: space-between;
  height: 100rpx;
  padding-left: 20rpx;
}

/**累计收入描述**/
.zong_shouyi_desc {
  font-size: 26rpx;
}

/**累计收入文本**/
.zong_shouyi_txt {
  font-size: 26rpx;
}

.beidong_shouyi {
  padding-right: 200rpx;
}

.gaoqian {
  margin-top: 30rpx;
  padding-top: 20rpx;
  height: 250rpx;
  background-color: white;
  margin-left: 25rpx;
  margin-right: 25rpx;
  border-radius: 10rpx;
  /**border: solid 1rpx red;**/
}

.gaoqian_title {
  display: flex;
  font-size: 32rpx;
}

.gaoqian_kinds {
  display: flex;
  justify-content: space-around;
  margin-top: 30rpx;
  font-size: 30rpx;
}

.setting {
  height: 100rpx;
  background-color: white;
  margin-top: 25rpx;
  margin-left: 25rpx;
  margin-right: 25rpx;
  border-radius: 10rpx;
  display: flex;
  justify-content: space-start;
  align-items: center;
}

/**自定义弹窗**/
/**遮罩层底层背景图**/
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5); // 半透明遮罩层颜色
  z-index: 91;
}

.laybg {
  position: fixed;
  top: 300rpx;
  right: 108rpx;
  z-index: 92;
  height: 520rpx;
  width: 520rpx;
  color: rgba(0, 0, 0, 0.5);
}

/** 关闭按钮**/
.close {
  position: fixed;
  top: 310rpx;
  right: 130rpx;
  z-index: 93;
  font-size: 36rpx;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.5);
  /** border:  solid 1rpx red;**/
  width: 50rpx;
  width: 60rpx;
  display: flex;
  justify-content: center;
}

/**锁图标**/
.lock {
  position: fixed;
  top: 400rpx;
  right: 250rpx;
  z-index: 93;
  width: 200rpx;
  height: 180rpx;
  color: rgba(0, 0, 0, 0.5);
}

.laytxt {
  position: fixed;
  top: 650rpx;
  right: 160rpx;
  z-index: 93;
  width: 360rpx;
  font-weight: 600;
}
</style>
